#pragma once

#include "LayerBase.h"
#include "ui/UIButton.h"
#include "ui/UIListView.h"
#include <vector>
#include <queue>
#include "CommonUiUtil.h"

class CLayerGroup : public CLayerBase {
	enum GroupListIndex {
		GLIMyGroup,
		GLIListGroup,
		GLITempUser,
	};
public:
	CLayerGroup(void);
	virtual ~CLayerGroup(void);
	CREATE_FUNC(CLayerGroup);

	bool init() override;
	virtual void onEnter() override;
	//virtual void onExit() override;
	//virtual void update(float delta) override;

	void FlushMyGroup();
	void FlushListGroup();
	void FlushTempUser();
private:
	void onClose(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onCreateGroup(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onApplyGroup(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onAgreeGroup(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onLeaveGroup(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onMyGroup(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onListGroup(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onTempUser(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onGetList(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);

	void onFlushMyGroup();
	void onFlushListGroup();
	void onFlushTempUser();
private:
	cocos2d::Node*				m_Group;
	cocos2d::ui::Button*		m_Close;

	cocos2d::ui::Button*		m_CreateGroup;
	cocos2d::ui::Button*		m_ApplyGroup;
	cocos2d::ui::Button*		m_AgreeGroup;
	cocos2d::ui::Button*		m_LeaveGroup;

	cocos2d::ui::Button*		m_MyGroup;
	cocos2d::ui::Button*		m_ListGroup;
	cocos2d::ui::Button*		m_TempUser;
	cocos2d::ui::Button*		m_GetList;

	cocos2d::ui::ListView*		m_GroupList;

	GroupListIndex				m_ListIndex;

	CCommonUiUtil::VecNode_t	m_ListNode;
};

